//
//  BaseModek.m
//  UI_豆瓣
//
//  Created by dllo on 15/12/24.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "BaseModek.h"

@implementation BaseModek
- (instancetype)initWithDic:(NSDictionary *)dic {
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

+ (instancetype)modelWithDic:(NSDictionary *)dic {
    // [self class] 表示当前类
    id m = [[[self class] alloc] initWithDic:dic];
    return m;
}
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
}

+ (NSMutableArray *)modelHanderWithArray:(NSArray *)arr {
    // 1. 创建空数组 保存处理后打的model对象
    NSMutableArray *mArray = [NSMutableArray array];
    // 2.遍历传入的数组参数得到每个字典信息
    for (NSDictionary *dic in arr) {
        // 3. 使用KVC转化对象
      id m = [[self class] modelWithDic:dic];
        // 4. 添加到数组
        [mArray addObject:m];
    }
    return mArray;
}

@end
